package com.wanxi.config.listener;

import com.wanxi.service.ContactService;
import com.wanxi.vo.ContactVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Slf4j
public class ContactAddListener {
    @Autowired
    ContactService contactService;

    @RabbitListener(queuesToDeclare = @Queue("wx_contact"))// 这个也可以，只是这个传的是Queue对象。
    public void receive(@Payload ContactVO body){
        contactService.addContact(body);
    }
}
